<template>
    <!-- 
    <b-modal ref="my-modal" hide-footer title="Using Component Methods">
     <div class="d-block text-center">
       <h3>Hello From My Modal!</h3>
     </div>
     <b-button class="mt-3" variant="outline-danger" block @click="hideModal">Close Me</b-button>
     <b-button class="mt-2" variant="outline-warning" block @click="toggleModal">Toggle Me</b-button>
   </b-modal> 
    -->
    <!--
        body-class="modalStyle" 表示样式
        size="lg" 表示模态窗口大小 xl,lg,sm,full
        hide-footer 表示隐藏底部按钮
        hide-header 表示隐藏头部内容
        no-close-on-backdrop 表示鼠标点击背景不可关闭
        hide-header-close 表示隐藏头部关闭按钮
        centered 居中
        ok-title=“确定” 
        cancel-title=取消
        @ok="handleOk" 
        @cancel="handleCancel"
        scrollable 滚动条
        hide-backdrop 隐藏背景
        wrapClassName="ant-modal-cust-warp" 
        style="top:5%;height: 85%;overflow-y: hidden" 样式
    -->
    <b-modal ref="my-modal" size="xl" title="附件详情" hide-footer scrollable no-close-on-backdrop>
        <div class="d-block text-center">
            <!--begin::div-->
            <div class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed">
                <div class="m-portlet__body">
                    <div class="form-group m-form__group row">                        
                        <label class="col-form-label">附件名称</label>
                        <div class="col-lg-6">
                            <input class="form-control" type="text" maxlength="255" v-model="attachmentForm.name">
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-form-label">原&nbsp;&nbsp;名&nbsp;称</label>
                        <div class="col-lg-6">
                            <input class="form-control" type="text" maxlength="255" v-model="attachmentForm.title">
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-form-label">件文类型</label>
                        <div class="col-lg-2">
                            <input class="form-control" type="text" maxlength="500" v-model="attachmentForm.type">
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-form-label">件文大小</label>
                        <div class="col-lg-2">
                            <input class="form-control" type="text" maxlength="20" v-model="attachmentForm.size">
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-form-label">相对路径</label>
                        <div class="col-lg-6">
                            <input class="form-control" type="text" maxlength="255" v-model="attachmentForm.path">
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-form-label">状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态</label>
                        <div class="col-lg-1">
                            <div v-if="attachmentForm.delFlag == 0">
                                <label class="col-form-label"><b-badge class="mr-1" variant="primary">正常</b-badge></label>
                            </div>
                            <div v-else-if="attachmentForm.delFlag == 1">
                                <label class="col-form-label"><b-badge class="mr-1" variant="danger">已删除</b-badge></label>
                            </div>
                            <div v-else>
                                <label class="col-form-label"><b-badge class="mr-1" variant="secondary">未知</b-badge></label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-form-label">顺&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;序</label>
                        <div class="col-lg-1">
                            <input class="form-control" maxlength="10" value="0"  v-model="attachmentForm.modulesOrder" >
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-form-label">绝对路径</label>
                        <div class="col-lg-4">
                            <input class="form-control" type="text" maxlength="255" v-model="attachmentForm.pathAbsolutek">
                        </div>
                        <label class="col-form-label" style="color: red;">*平台路径配置中心键（自定义上传绝对路径使用）</label>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-form-label">相对路径</label>
                        <div class="col-lg-4">
                            <input class="form-control" type="text" maxlength="255" v-model="attachmentForm.pathRelativek">
                        </div>
                        <label class="col-form-label" style="color: red;">*平台路径配置中心键（自定义上传相对路径使用）</label>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-form-label">上传路径</label>
                        <div class="col-lg-4">
                            <input class="form-control" type="text" maxlength="255" v-model="attachmentForm.pathUrlk" >
                        </div>
                        <label class="col-form-label" style="color: red;">*平台路径配置中心键（自定义上传路径 自定义URL地址）</label>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-form-label">上传时间</label>
                        <div class="col-lg-2">
                            <input class="form-control" type="text" maxlength="20"  v-model="attachmentForm.createTime">
                        </div>
                    </div>
                    <div class="form-group m-form__group row">
                        <label class="col-form-label">上&nbsp;&nbsp;传&nbsp;&nbsp;者</label>
                        <div class="col-lg-2">
                            <input class="form-control" type="text" maxlength="32" v-model="attachmentForm.createBy">
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <template slot="modal-footer">
            <!--自定义按钮-->
        </template>
    </b-modal>
</template>
<script>
import apiUtil from "@/core/util/apiUtil.js";
import { handleNotify, handleAlert, handleConfirm, showWating, closeWating } from "@/core/util/jehcUtil.js";
export default {
    data() {
        return {
            attachmentForm: {
                delFlag:"",
                name:"",
                type:"",
                size:"",
                path:"",
                title:"",
                modulesOrder: "",
                pathAbsolutek: "",
                pathRelativek: "",
                pathUrlk: "",
                createTime: "",
                createBy: "",

            }
        }
    },
    components: {

    },
    watch: {
    },
    mounted() {

    },
    methods: {
        showModal(id) {
            this.restForm();
            this.$refs['my-modal'].show();
            this.getDetail(id);
        },
        hideModal() {
            this.$refs['my-modal'].hide()
        },
        toggleModal() {
            // 当模态已隐藏时，我们传递要返回焦点的按钮的ID
            this.$refs['my-modal'].toggle('#toggle-btn')
        },
        restForm() {
            //重置
            Object.assign(this.$data.attachmentForm, this.$options.data().attachmentForm);
        },
        getDetail(id){
            apiUtil.get(process.env.VUE_APP_FILE_API+"/attachment/get/"+id).then(({ data }) => {
                this.attachmentForm = data.data;
            });
        },
    }
}
</script>